package pe.gob.osinergmin.activity.dialog;

import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;

import pe.gob.osinergmin.R;
import pe.gob.osinergmin.activity.generic.GenericDialog;

public class ExitDialog extends GenericDialog implements View.OnClickListener {

    private TextView btnSalirSI;
    private TextView btnSalirNO;

    public ExitDialog(Context context) {
        super(context);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_exit);
        getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
        getWindow().setGravity(Gravity.CENTER_HORIZONTAL|Gravity.CENTER_VERTICAL);

        btnSalirSI = (TextView) findViewById(R.id.btnSalirSI);
        btnSalirNO = (TextView) findViewById(R.id.btnSalirNO);

        btnSalirSI.setOnClickListener(this);
        btnSalirNO.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {

        if(v.getId() == R.id.btnSalirSI){
            this.dismiss();
            Intent intent = new Intent(Intent.ACTION_MAIN);
            intent.addCategory(Intent.CATEGORY_HOME);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            getContext().startActivity(intent);
            //((Activity)((ContextThemeWrapper)getContext()).getBaseContext()).finish();
        }
        if(v.getId() == R.id.btnSalirNO){
            this.dismiss();
        }
    }
}
